// 场站管理接口
import { default as request, download } from '@/utils/request'
// import { getUser, getToken } from '@/utils/auth'
import qs from 'qs'
// import { resetPassword } from './user'

// 获取场站列表
export function getStationList(data) {
  return request({
    url: '/station/page/get',
    method: 'post',
    data
  })
}

// 更新工单
export function updatePush(data) {
  return request({
    url: '/station/updatePush',
    method: 'put',
    data
  })
}

// 第三方是否开放
export function thirdOpen(data) {
  return request({
    url: '/station/thirdOpen',
    method: 'put',
    data
  })
}

// 添加场站
export function addStation(data) {
  return request({
    url: '/station/add',
    method: 'post',
    data
  })
}

// 修改场站
export function putStation(data) {
  return request({
    url: '/station/save',
    method: 'post',
    data
  })
}

// 删除场站
export function delStation(data) {
  return request({
    url: '/station/del/' + data.stationId,
    method: 'delete',
    headers: { 'content-type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(data)
  })
}

// 导出数据
export function exportStation(data) {
  return request({
    url: '/v2/station/download',
    method: 'post',
    data,
    responseType: 'arraybuffer'
  }).then(res => {
    return download(res)
  })
}

// 下载模板
export function downloadTemplate(data) {
  return request({
    url: '/v2/station/template',
    method: 'get',
    data: qs.stringify(data),
    responseType: 'arraybuffer'
  }).then(res => {
    return download(res)
  })
}

// 按id获取场站
export function getStation(stationId) {
  return request({
    url: `/station/get/${stationId}`,
    method: 'get'
  })
}
